from time import sleep

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
driver.maximize_window()

driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()
sleep(1)

# 定位一组元素
texts = driver.find_elements_by_xpath("//div[@tpl='se_com_default']/h3/a")
print(len(texts))
for i in texts:
    print(i.text)

driver.quit()
